<template>
  <a-card :bordered="false" >
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <!-- useful_auto_generate_section_start -->
          
          <a-col :md="6" :sm="12">
            <a-form-item label="名称">
              <a-input v-model="queryParam.name" placeholder="请输入名称" />
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="12">
            <a-form-item label="美国音标">
              <a-input v-model="queryParam.usPhoneticSymbol" placeholder="请输入美国音标" />
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="12">
            <a-form-item label="英国音标">
              <a-input v-model="queryParam.ukPhoneticSymbol" placeholder="请输入英国音标" />
            </a-form-item>
          </a-col>
          <!-- useful_auto_generate_section_end -->

          <template v-if="toggleSearchStatus">
            <!-- useful_auto_generate_section_start -->
            <a-col :md="6" :sm="12">
              <a-form-item label="美国发音">
                <a-input v-model="queryParam.usPronunciation" placeholder="请输入美国发音" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="英国发音">
                <a-input v-model="queryParam.ukPronunciation" placeholder="请输入英国发音" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="等级标签">
                <a-input v-model="queryParam.levelTags" placeholder="请输入等级标签" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="名词">
                <a-input v-model="queryParam.noun" placeholder="请输入名词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="代词">
                <a-input v-model="queryParam.pron" placeholder="请输入代词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="形容词">
                <a-input v-model="queryParam.adj" placeholder="请输入形容词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="副词">
                <a-input v-model="queryParam.adv" placeholder="请输入副词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="动词">
                <a-input v-model="queryParam.verb" placeholder="请输入动词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="数词">
                <a-input v-model="queryParam.num" placeholder="请输入数词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="冠词">
                <a-input v-model="queryParam.art" placeholder="请输入冠词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="介词">
                <a-input v-model="queryParam.prep" placeholder="请输入介词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="连词">
                <a-input v-model="queryParam.conj" placeholder="请输入连词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="感叹词">
                <a-input v-model="queryParam.interj" placeholder="请输入感叹词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="名词复数">
                <a-input v-model="queryParam.nounPlural" placeholder="请输入名词复数" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="第三人称单数">
                <a-input v-model="queryParam.thirdSingle" placeholder="请输入第三人称单数" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="现在分词">
                <a-input v-model="queryParam.participle" placeholder="请输入现在分词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="过去式">
                <a-input v-model="queryParam.pastTense" placeholder="请输入过去式" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="过去分词">
                <a-input v-model="queryParam.pastParticiple" placeholder="请输入过去分词" />
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="12">
              <a-form-item label="创建时间">
                <a-range-picker v-model="queryParam.gmtCreate" :style="{width: '230px'}" :placeholder="['开始时间', '结束时间']" format="YYYY-MM-DD" @change="(v)=>handleRangeDateChange(v,{startProperty:'gmtCreateStart',endProperty:'gmtCreateEnd'})" />
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="12">
              <a-form-item label="修改时间">
                <a-range-picker v-model="queryParam.gmtModified" :style="{width: '230px'}" :placeholder="['开始时间', '结束时间']" format="YYYY-MM-DD" @change="(v)=>handleRangeDateChange(v,{startProperty:'gmtModifiedStart',endProperty:'gmtModifiedEnd'})" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="类型">
                <a-select v-model="queryParam.type" :options="typeOptions"  />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="缩写">
                <a-input v-model="queryParam.abbr" placeholder="请输入缩写" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="助动词">
                <a-input v-model="queryParam.aux" placeholder="请输入助动词" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="其他注释">
                <a-input v-model="queryParam.otherComment" placeholder="请输入其他注释" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="比较级">
                <a-input v-model="queryParam.comparative" placeholder="请输入比较级" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="最高级">
                <a-input v-model="queryParam.superlative" placeholder="请输入最高级" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="12">
              <a-form-item label="限定词">
                <a-input v-model="queryParam.det" placeholder="请输入限定词" />
              </a-form-item>
            </a-col>
            <!-- useful_auto_generate_section_end -->


          </template>

          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>

      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;" v-if="selectedRowKeys.length > 0">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
        selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

            <a-table
              ref="table"
              size="middle"
              :scroll="{x:true}"
              bordered
              rowKey="id"
              :columns="columns"
              :dataSource="dataSource"
              :pagination="ipagination"
              :loading="loading"
              :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
              class="j-table-force-nowrap"
              @change="handleTableChange">



              <span slot="action" slot-scope="text, record">
                <a @click="handleEdit(record)">编辑</a>

                <a-divider type="vertical" />
                <a-dropdown>
                  <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                  <a-menu slot="overlay">
                    <a-menu-item>
                      <a @click="handleDetail(record)">详情</a>
                    </a-menu-item>

                    <a-menu-item>
                      <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                        <a>删除</a>
                      </a-popconfirm>
                    </a-menu-item>


                  </a-menu>
                </a-dropdown>
              </span>

            </a-table>

    </div>

    <wordDict-modal ref="modalForm" @ok="modalFormOk"></wordDict-modal>

  </a-card>
</template>

<script>


  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { FormMixin } from '@/mixins/FormMixin'
  import WordDictModal from './WordDictModal'
  import { getDataOptionList } from '@/utils/util'
  import { requestSetOptions,requestSetData } from '@/utils/commonUtils'
  import moment from 'moment'

  export default {
    name: 'WordDictList',
    mixins: [JeecgListMixin, FormMixin,mixinDevice],
    components: {
      WordDictModal,
    },
    data() {
      return {
        description: '',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            // fixed: 'left',
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },

          //useful_auto_generate_section_start
          {
          title: '名称',
          dataIndex: 'name',
          width: 100,
          align: 'center',
          },
          {
          title: '美国音标',
          dataIndex: 'usPhoneticSymbol',
          width: 100,
          align: 'center',
          },
          {
          title: '英国音标',
          dataIndex: 'ukPhoneticSymbol',
          width: 100,
          align: 'center',
          },
          {
          title: '美国发音',
          dataIndex: 'usPronunciation',
          width: 100,
          align: 'center',
          },
          {
          title: '英国发音',
          dataIndex: 'ukPronunciation',
          width: 100,
          align: 'center',
          },
          {
          title: '等级标签',
          dataIndex: 'levelTags',
          width: 100,
          align: 'center',
          },
          {
          title: '名词',
          dataIndex: 'noun',
          width: 100,
          align: 'center',
          },
          {
          title: '代词',
          dataIndex: 'pron',
          width: 100,
          align: 'center',
          },
          {
          title: '形容词',
          dataIndex: 'adj',
          width: 100,
          align: 'center',
          },
          {
          title: '副词',
          dataIndex: 'adv',
          width: 100,
          align: 'center',
          },
          {
          title: '动词',
          dataIndex: 'verb',
          width: 100,
          align: 'center',
          },
          {
          title: '数词',
          dataIndex: 'num',
          width: 100,
          align: 'center',
          },
          {
          title: '冠词',
          dataIndex: 'art',
          width: 100,
          align: 'center',
          },
          {
          title: '介词',
          dataIndex: 'prep',
          width: 100,
          align: 'center',
          },
          {
          title: '连词',
          dataIndex: 'conj',
          width: 100,
          align: 'center',
          },
          {
          title: '感叹词',
          dataIndex: 'interj',
          width: 100,
          align: 'center',
          },
          {
          title: '名词复数',
          dataIndex: 'nounPlural',
          width: 100,
          align: 'center',
          },
          {
          title: '第三人称单数',
          dataIndex: 'thirdSingle',
          width: 100,
          align: 'center',
          },
          {
          title: '现在分词',
          dataIndex: 'participle',
          width: 100,
          align: 'center',
          },
          {
          title: '过去式',
          dataIndex: 'pastTense',
          width: 100,
          align: 'center',
          },
          {
          title: '过去分词',
          dataIndex: 'pastParticiple',
          width: 100,
          align: 'center',
          },
          {
          title: '创建时间',
          dataIndex: 'gmtCreate',
          width: 100,
          align: 'center',
          },
          {
          title: '修改时间',
          dataIndex: 'gmtModified',
          width: 100,
          align: 'center',
          },
          {
          title: '类型',
          dataIndex: 'typeEnum.text',
          width: 100,
          align: 'center',
          },
          {
          title: '缩写',
          dataIndex: 'abbr',
          width: 100,
          align: 'center',
          },
          {
          title: '助动词',
          dataIndex: 'aux',
          width: 100,
          align: 'center',
          },
          {
          title: '其他注释',
          dataIndex: 'otherComment',
          width: 100,
          align: 'center',
          },
          {
          title: '比较级',
          dataIndex: 'comparative',
          width: 100,
          align: 'center',
          },
          {
          title: '最高级',
          dataIndex: 'superlative',
          width: 100,
          align: 'center',
          },
          {
          title: '限定词',
          dataIndex: 'det',
          width: 100,
          align: 'center',
          },
          //useful_auto_generate_section_end
          {
            title: '操作',
            dataIndex: 'action',
            fixed:'right',
            scopedSlots: {customRender: 'action'},
            align: "center",
            width: 170
          }

        ],

        url: {
          list: '/english/wordDict/list',
          delete: '/english/wordDict/del',
          deleteBatch: '/english/wordDict/del',

        },
      //useful_auto_generate_section_start
      typeOptions:getDataOptionList('wordDictTypeEnum'),
      //useful_auto_generate_section_end
        superFieldList: [],
      }
    },
    created() {

      let $this = this;
      //useful_auto_generate_section_start
      
      //useful_auto_generate_section_end


    },
    computed: {
    },
    methods: {
      initDictConfig() {
      },
      initRefresh(nodeId){
        // if(nodeId.startsWith("a")){
        //   this.queryParam.articleId = nodeId.substr(1,nodeId.length-1);
        //   this.searchQuery();
        // }

      },

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
